package com.example.diary;
import android.content.Context;
import android.database.Cursor;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.timecalculous.R;

public class DiaryAdapter extends BaseAdapter{
    public LayoutInflater inflater;
    private Cursor mCursor;

    public DiaryAdapter(Context context, Cursor cursor){
        mCursor = cursor;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return mCursor.getCount();
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView=inflater.inflate(R.layout.diarylist,null);
        TextView txt1,txt2;
        txt1= (TextView) convertView.findViewById(R.id.diaryTxt1);
        txt2= (TextView) convertView.findViewById(R.id.diaryTxt2);
        mCursor.moveToPosition(position);
        txt1.setText(mCursor.getString(1)+"年"+mCursor.getString(2)+"月"+mCursor.getString(3)+"日");
        txt2.setText(mCursor.getString(4));
        return convertView;
    }
}
